package com.lhalcyon.dapp.manager;

import android.app.Dialog;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;

import com.lhalcyon.dapp.R;

public class WalletPassWordDialog extends DialogFragment {

    public static WalletPassWordDialog newInstance() {
        WalletPassWordDialog csdf = new WalletPassWordDialog();
        return csdf;
    }

    public WalletPassWordDialog() {
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @NonNull
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        return super.onCreateDialog(savedInstanceState);
    }

    @Override
    public void onStart() {
        super.onStart();
        Dialog dialog = getDialog();
        if (dialog != null) {
            DisplayMetrics dm = new DisplayMetrics();
            getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);

            Window window = getDialog().getWindow();
            WindowManager.LayoutParams lp = window.getAttributes();
//            lp.gravity = Gravity.BOTTOM; // 紧贴底部
            lp.width=(int) (dm.widthPixels * 0.75);
            window.setAttributes(lp);

        }
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
        getDialog().getWindow().setBackgroundDrawableResource(android.R.color.transparent);

        View view = inflater.inflate(R.layout.dialog_wallet_pwd, container, false);

        return view;
    }
}
